package com.winteam.View;

import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import java.util.Vector;

public class Custom_type extends JFrame{


    private JPanel contentPane;
    private JTextField textField;

    private DefaultTableModel model;

    private JTable table;
    private JButton btnNewButton;
    private JButton btnNewButton_1;
    private JButton btnNewButton_2;
    private JLabel lblNewLabel;
    private JTextField textField_1;
    private JButton btnNewButton_3;
    private JButton btnNewButton_4;
    private JButton btnNewButton_5;
    private JPanel panel;
    private JLabel lblNewLabel_1;




    public Custom_type () {
        setSize(950,650);
        setTitle("客户预定");
        setLocationRelativeTo(null);
        contentPane = new JPanel();
        contentPane.setBackground(new Color(231,215,183));

        contentPane.setLayout(null);
        setContentPane(contentPane);




        btnNewButton = new JButton("增加",new ImageIcon(getClass().getResource("img/new.gif")));
        btnNewButton.setBounds(27, 31, 85, 36);
        btnNewButton.setOpaque(false);
        btnNewButton.setFocusPainted(false);//去掉按钮周围的焦点框
        btnNewButton.setContentAreaFilled(false);//设置按钮透明背景
        contentPane.add(btnNewButton);


        btnNewButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                ReservationUi reservationUi = new ReservationUi();
                reservationUi.setVisible(true);
            }
        });
        btnNewButton_1 = new JButton("修改",new ImageIcon(getClass().getResource("img/modi0.gif")));
        btnNewButton_1.setFocusPainted(false);//去掉按钮周围的焦点框
        btnNewButton_1.setContentAreaFilled(false);//设置按钮透明背景
        btnNewButton_1.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                ReservationAlter ra = new ReservationAlter();
                ra.setVisible(true);
            }
        });
        btnNewButton_1.setBounds(127, 31, 85, 36);
        contentPane.add(btnNewButton_1);

        btnNewButton_2 = new JButton("删除",new ImageIcon(getClass().getResource("img/del.gif")));
        btnNewButton_2.setBounds(215, 31, 85, 36);
        btnNewButton_2.setFocusPainted(false);//去掉按钮周围的焦点框
        btnNewButton_2.setContentAreaFilled(false);//设置按钮透明背景
        contentPane.add(btnNewButton_2);

        lblNewLabel = new JLabel("房间  /  电话  /  姓名:");
        lblNewLabel.setBounds(313, 40, 116, 18);
        contentPane.add(lblNewLabel);

        textField_1 = new JTextField();
        textField_1.setBounds(429, 37, 155, 24);
        contentPane.add(textField_1);
        textField_1.setColumns(10);

        btnNewButton_3 = new JButton("查询",new ImageIcon(getClass().getResource("img/find.gif")));
        btnNewButton_3.setBounds(612, 31, 85, 36);
        btnNewButton_3.setFocusPainted(false);//去掉按钮周围的焦点框
        btnNewButton_3.setContentAreaFilled(false);//设置按钮透明背景
        contentPane.add(btnNewButton_3);

        btnNewButton_4 = new JButton("刷新",new ImageIcon(getClass().getResource("img/b1.gif")));
        btnNewButton_4.setBounds(704, 31, 85, 36);
        btnNewButton_4.setFocusPainted(false);//去掉按钮周围的焦点框
        btnNewButton_4.setContentAreaFilled(false);//设置按钮透明背景
        contentPane.add(btnNewButton_4);

        btnNewButton_5 = new JButton("开设房间",new ImageIcon(getClass().getResource("img/modi3.gif")));
        btnNewButton_5.setBounds(805, 31, 110, 36);
        btnNewButton_5.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                ReservationUi reservationUi= new ReservationUi();
                reservationUi.setVisible(true);
            }
        });
        btnNewButton_5.setFocusPainted(false);//去掉按钮周围的焦点框
        btnNewButton_5.setContentAreaFilled(false);//设置按钮透明背景
        contentPane.add(btnNewButton_5);

        setModel( null);
        table = new JTable(model);

        JScrollPane scrollPane = new JScrollPane(table);
        scrollPane.setOpaque(true);
        scrollPane.setBounds(27, 121, 891, 469);
        table.setBackground(new java.awt.Color(231,215,183));
        table.setOpaque(false);
        scrollPane.setBackground(new Color(231,215,183));
        panel = new JPanel();
        panel.setBackground(new Color(199,183,143));
        panel.setBounds(27, 80, 891, 28);
        contentPane.add(panel);

        lblNewLabel_1 = new JLabel("宾客预定信息");
        panel.add(lblNewLabel_1);
        contentPane.add(scrollPane);

    }
    public void setModel(List list) {

        Vector<String> header = new Vector<String>();
        header.add("宾客姓名");
        header.add("联系电话");
        header.add("预定房间类型 ");
        header.add("预定房间编号");
        header.add("预定时间");
        header.add("保留");
        header.add("备注");

        Vector<Vector<Object>> body = new Vector<Vector<Object>>();
        if(model == null) {
            model = new DefaultTableModel(body,header);
        }else {
            model.setDataVector(body, header);
        }


    }
    public static void main(String[] args) {
        new Custom_type().setVisible(true);
    }
}
